package com.heima.admin.controller.v1;

import com.heima.admin.service.SensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理controller",tags = "敏感词管理controller")
public class SensitiveController {
    @Autowired
     private SensitiveService sensitiveService;
    @ApiOperation("敏感词分页查询")
     @PostMapping("/list")
    public ResponseResult list(@RequestBody SensitiveDTO sensitiveDTO){
         return        sensitiveService.findListByQuery(sensitiveDTO);
    }

    @ApiOperation("添加敏感词")
    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdSensitive adSensitive){
        return        sensitiveService.insert(adSensitive);
    }

    @ApiOperation("修改敏感词信息")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdSensitive adSensitive){
        return        sensitiveService.update(adSensitive);
    }
    @ApiOperation(("删除敏感词信息"))
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return  sensitiveService.delete(id);
    }

    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives() {
        return sensitiveService.selectAllSensitives();
    }
}
